import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    // 动态导入,路由懒加载，需要时才加载特定的组件
    // component 属性的值是一个函数，这个函数返回了一个 Promise，这个 Promise 会在路由匹配到 /goods 路径时被解析
    {
      path: "/",
      component: () => import("../views/home.vue"),
    },
    {
      path: "/detail",
      component: () => import("../views/detail.vue"),
    },
    {
      path: "/home",
      component: () => import("../views/home.vue"),
      children: [
        {
          path: "/goods",
          component: () => import("../views/goodsPage/index.vue"),
        },
        {
          path: "/evaluate",
          component: () => import("../views/evaluatePage/index.vue"),
        },
        {
          path: "/merchant",
          component: () => import("../views/merchantPage/index.vue"),
        },
      ],
    },
  ],
});

export default router;
